package com.omybug.test;

import com.omybug.study.config.LifeConfig;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @author: omybug
 * @date: 18/9/18 14:55
 */
public class BeanLife {

    AnnotationConfigApplicationContext applicationContext;

    @Before
    public void init(){
        applicationContext = new AnnotationConfigApplicationContext(LifeConfig.class);
    }


    @Test
    public void test01(){
//        String[] beanDefinitionNames = applicationContext.getBeanDefinitionNames();
//        for (String name : beanDefinitionNames) {
//            System.out.println(name);
//        }
        applicationContext.close();
    }

    @Test
    public void testListener(){
        applicationContext.publishEvent(new ApplicationEvent("我的事件") {
        });
        applicationContext.close();
    }
}
